# 爬虫：通过编写程序来获取互联网上的资源
# 步骤：
#

from urllib.request import urlopen

url = 'http://www.baidu.com/'
response = urlopen(url)
# print(response.read())  # 输出的是字节
# print(response.read().decode('utf-8'))  # 将输出的字节转成字符串

with open('../爬虫文件/百度.html', mode='w', encoding='utf-8') as file:
    file.write(response.read().decode("utf-8"))  # 读取爬到网页的源代码

print('over')
response.close()